gusucode.com > 支持向量机工具箱 - LIBSVM OSU_SVM LS_SVM源码程序 > 支持向量机工具箱 - LIBSVM OSU_SVM LS_SVM\stprtool\pca\pkernelpca.m

    function pkernelpca(T,features,ker,arg,contour_num)
% PKERNELPCA plots Kernel-PCA feature extraction for 2D data.
%  pkernelpca(T,features,ker,arg)
% 
% The Kernel-PCA non-linearly map the data into high dimensional 
% space and then reduces their dimension by linear (standard) PCA.
%
% The points in the original space which have the equal value of 
% extracted feature form contours. The contours show main variance 
% in the data. These contours can be displayed by pkernelpca 
% function.
% 
% Input:
%  T [NxL] L training patterns in N-dimensional space.
%  features [...] enumeration of extracted features to be displayed. 
%     For example, [1,2,7] means the 1st, 2nd and the 7th feature. 
%     The features are numbered according to their eigenvalues.
%  ker [string] kernel identifier, see help kernel.
%  arg [...] arguments of given kernel.
%  contour_num [1x1] number of contours for one feature. Default is 8.
%  
% See also KERNELPCA, KERNEL, SPCA.
%

% Statistical Pattern Recognition Toolbox, Vojtech Franc, Vaclav Hlavac
% (c) Czech Technical University Prague, http://cmp.felk.cvut.cz
% Modifications:
% 8-July-2001, V.Franc 

% Default number of contours.
if nargin < 5,
  contour_num = 8;
end

hold on;
xgrid = 25;
ygrid = 25;

% Testing points - grid [xgrid x ygrid].
w = axis;
xrange=w(1):(w(2)-w(1))/xgrid:w(2);
yrange=w(3):(w(4)-w(3))/ygrid:w(4);

[X,Y] = meshgrid(xrange,yrange);
Xtst=[reshape(X,1,prod(size(X)));reshape(Y,1,prod(size(Y)))];


% Call Kernel-PCA
Z = kernelpca(Xtst, T, max(features), ker, arg );


% Plot contours of selected features.
for i=features,
  map = reshape(Z(i,:), length(yrange), length(xrange));
  contour(xrange, yrange, map, contour_num, color(i));
end

hold off;

return;